package hn.security.controller;


import hn.security.message.SecurityResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * API接口
 */
@RestController
@RequestMapping("/security")
public class SecurityController {

    private static final Logger logger = LoggerFactory.getLogger(SecurityController.class);


    @Secured("hasAnyRole('system')")
    @GetMapping("getAllApi")
    public SecurityResponse<String> getAllApi() {
        SecurityResponse<String> securityResponse = SecurityResponse.success("");
        securityResponse.setData("");
        return securityResponse;
    }

    @PreAuthorize("hasAnyRole('system1')")
    @GetMapping("getOwnApi")
    public SecurityResponse<String> getOwnApi() {
        SecurityResponse<String> securityResponse = SecurityResponse.success("");
        securityResponse.setData("");
        return securityResponse;
    }


    @GetMapping(value = "getApi")
    public ResponseEntity<String> getApi() {
        return ResponseEntity.ok("getApi");
    }

    @GetMapping(value = "getStr")
    public String getString() {
        return "getStr";
    }

}
